package com.course.web.model;

import com.course.domain.enums.TaskType;
import com.course.util.TimeUtils;
import lombok.Data;

/**
 * Created by Justin on 2017/6/13.
 */
@Data
public class AgendaItemVM {
    private final int partIdx;
    private final int weekDay;
    private final TaskType type;
    private int time;

    public int getHH() {
        return TimeUtils.getHH(time);
    }

    public int getMM() {
        return TimeUtils.getMM(time);
    }

    public void setHH(int hh) {
        time = TimeUtils.toTime(hh, getMM());
    }

    public void setMM(int mm) {
        time = TimeUtils.toTime(getHH(), mm);
    }

    public String getTitle() {
        if (type.equals(TaskType.NONE)) {
            return "";
        }
        return String.format("%s(%02d:%02d)", type.getTitle(), getHH(), getMM());
    }
}
